package cn.com.homeyoda.aimate.aihealth.ui.questionnaire;

import static cn.com.homeyoda.aimate.aihealth.utils.AppConstants.ID;
import static cn.com.homeyoda.aimate.aihealth.utils.AppConstants.TITLE;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.lifecycle.ViewModelProviders;

import cn.com.homeyoda.aimate.aihealth.BR;
import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.app.AppViewModelFactory;
import cn.com.homeyoda.aimate.aihealth.base.BaseActivity;
import cn.com.homeyoda.aimate.aihealth.base.BaseViewModel;
import cn.com.homeyoda.aimate.aihealth.databinding.ActivityQuestionnaireCoverBinding;

public class QuestionnaireCoverActivity extends BaseActivity<ActivityQuestionnaireCoverBinding, BaseViewModel> implements View.OnClickListener {

    public static void start(Context context, String id, String title) {
        Intent starter = new Intent(context, QuestionnaireCoverActivity.class);
        starter.putExtra(ID, id);
        starter.putExtra(TITLE, title);
        context.startActivity(starter);
    }

    @Override
    public BaseViewModel initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(BaseViewModel.class);
    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_questionnaire_cover;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        initView();
    }

    private void initView() {
        binding.titleBar.ivBack.setOnClickListener(this);
        binding.btnJoin.setOnClickListener(this);
        binding.titleBar.tvTitle.setText(getString(R.string.questionnaires));
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();
    }

    @Override
    public void onClick(View v) {
        int vId = v.getId();
        if (vId == R.id.iv_back) {
            finish();
        } else if (vId == R.id.btn_join) {
            String id = getIntent().getStringExtra(ID);
            String title = getIntent().getStringExtra(TITLE);
            QuestionnaireTopicActivity.start(this, id, title);
        }
    }

}